class Solution {
public:
    int ret;
    int aim;
    int findTargetSumWays(vector<int>& nums, int target) {
        aim=target;
        dfs(nums,0,0);
        return ret;
    }
    void dfs(vector<int>& nums,int pos,int path)
    {
        if(pos==nums.size())
        {
            if(path==aim)
                ret++;
            return;
        }
        dfs(nums,pos+1,path+nums[pos]);

        dfs(nums,pos+1,path-nums[pos]);

    }
};
